# Importing Data
VIETNAM<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "j1:j325")

# Checking the Imported Data
View(VIETNAM)
# Creating Time Series Data
VIETNAM_ts <- ts(VIETNAM, start=c(1991,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
VIETNAM_ts
sum(is.na(VIETNAM_ts))
library(forecast)
VIETNAM_ts <- tsclean(VIETNAM_ts)
VIETNAM_ts

# Identification: Plotting the Time Series Data
plot(VIETNAM_ts)

# Estimating the appropriate model
VIETNAM_ts_model <- auto.arima(VIETNAM_ts)
VIETNAM_ts_model

# Forecasting
options(max.print=1000000)
VIETNAM_ts_forecast <- forecast (VIETNAM_ts_model, level=c(95), h=276)
plot(VIETNAM_ts_forecast)
VIETNAM_ts_forecast             

# Exporting
write.table(VIETNAM_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/VIETNAM_TSA.csv", sep=",")


